<template>
  <view class="order" @tap="toTaxi">
    <view class="left">
      <view class="item">
        <view class="dot" style="border-color: #ffba19"></view>
        <!-- 2022年1月18日 11:07 -->
        {{ getCurrentTime }}
      </view>
      <view class="item">
        <view class="dot" style="border-color: #3983f6"></view>
        <text
          style="
            width: 90%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          "
          >{{ orderItem.beginName }}</text
        >
      </view>
      <view class="item">
        <view class="dot" style="border-color: #f14942"></view>
        <text
          style="
            width: 90%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          "
          >{{ orderItem.endName }}</text
        >
      </view>
      <view class="money">
        <text>¥</text>
        16.00
      </view>
    </view>
    <view class="right">
      <view class="status">进行中</view>
      <image :src="orderItem.avatar" class="img" />
      <view class="user_name">
        <text
          style="
            width: 90%;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          "
          >{{ orderItem.nickname }}</text
        ></view
      >
    </view>
  </view>
</template>
<script>
import "./order.less";
import Taro from "@tarojs/taro";
export default {
  props: {
    orderItem: {},
  },
  data() {
    return {};
  },
  computed: {
    getCurrentTime() {
      const timestamp = new Date(Number(new Date()));
      return (
        timestamp.toLocaleDateString().replace(/\//g, "-") +
        " " +
        timestamp.toTimeString().substr(0, 8)
      );
    },
  },
  methods: {
    toTaxi() {
      var that = this;
      Taro.navigateTo({
        url: "/pages/taxi/taxi",
        success: function (res) {
          // 通过eventChannel向被打开页面传送数据
          res.eventChannel.emit("acceptDataFromOpenerPage", {
            data: {
              begin: that.orderItem.beginName,
              end: that.orderItem.endName,
            },
          });
        },
      });
    },
  },
};
</script>

